﻿namespace Gaming
{
    public abstract class  CardConstraint
    {
        public abstract bool Validate(TableGenerator tgen, int maxReadyIndex);
    }

    public class TableConstraint : CardConstraint
    {
        private CardSetList _include;
        private CardSetList _exclude;
        private int _start;
        private int _count;
        private CardSet _checked;

        public TableConstraint(CardSet check, CardSetList include, CardSetList exclude)
        {
            _include = include;
            _exclude = exclude;
            _checked = check;
        }

        #region ICardConstraint Members

        public override bool Validate(TableGenerator tgen, int maxReadyIndex)
        {

            if (_checked.IsReady(maxReadyIndex))
            {
                _checked.UpdateMask();
                if (null != _exclude && _exclude.Contains(_checked))
                    return false;
                if (null != _include && !_include.Contains(_checked))
                    return false;
                return true;
            }
            return true;
        }

        #endregion

        public override string ToString()
        {
            string r = "";
            if (null != _include)
                r += "INCL: " + _include.ToString();
            if (null != _exclude)
                r += " EXCL: " + _exclude.ToString();
            return r;
        }
    }
}